﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using namesMyDelegate;  //  MyDelegate

public partial class Delegate_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }

    private void Bind()
    {
        Heater heater = new Heater();
       Alarm alarm = new Alarm();

       heater.BoilEvent += alarm.MakeAlert;    //注册方法
       Label1.Text =  heater.BoilWater();   //烧水，会自动调用注册过对象的方法

       heater.BoilEvent += Display.ShowMsg;       //注册静态方法
       heater.BoilEvent += (new Alarm()).MakeAlert;   //给匿名对象注册方法
       Label2.Text = heater.BoilWater();
    }
}


